package com.wdl.networkflow.uv

import com.wdl.networkflow.pv.UserBehavior
import org.apache.flink.api.common.functions.AggregateFunction

class UvAgg() extends AggregateFunction[UserBehavior, Set[Long], Long]{

  override def createAccumulator(): Set[Long] = Set[Long]()

  override def add(value: UserBehavior, accumulator: Set[Long]): Set[Long] = accumulator + value.userId

  override def getResult(accumulator: Set[Long]): Long = accumulator.size

  override def merge(a: Set[Long], b: Set[Long]): Set[Long] = a ++ b
}
